package org.example.y25.m3;

public class leetcode_58 {
    static class Solution {
        public int lengthOfLastWord(String s) {
            int last_n = 0;
            for (int i = s.length() - 1; i >= 0; i--) {
                if(s.charAt(i) != ' '){
                    last_n++;
                }else{
                    if(last_n > 0){
                        break;
                    }
                }
            }
            return last_n;
        }
    }

    public static void main(String[] args) {
        System.out.println(new Solution().lengthOfLastWord("Today is a nice day"));
    }
}
